#ifndef JCMPLAYER_CCGLVIDEORENDER_H
#define JCMPLAYER_CCGLVIDEORENDER_H

#include <array>
#include <memory>
#include <chrono>
#include <map>
#include "CCOpenGLShader.h"
#include "CCNDKCommonDef.h"
#include "CCYUVDataDefine.h"

class CCGLVideoRender
{
public:
    CCGLVideoRender();
    ~CCGLVideoRender();

    void InitGL();
    void PaintGL();
    void ResizeGL(int w,int h);

    void SetupAssetManager(AAssetManager *pManager);

    void RendVideo(YUVData_Frame *frame);

private:
    void loadShaderResources(AAssetManager *pManager);

private:
    AAssetManager *m_pAssetManager;
    std::unique_ptr<CCOpenGLShader> m_pOpenGLVideoShader;

    bool m_bUpdateData = false;

    GLuint m_textures[3];

    int m_nVideoW = 0; // 视频分辨率宽
    int m_nVideoH = 0; // 视频分辨率高
    int m_yFrameLength = 0;
    int m_uFrameLength = 0;
    int m_vFrameLength = 0;

    std::unique_ptr<unsigned char[]> m_pBufYuv420p;

    struct CCVertex
    {
        float x, y, z; // 顶点坐标
        float u, v;    // 纹理uv坐标
    };
};

#endif // JCMPLAYER_CCGLVIDEORENDER_H
